<?php
   require("db.php");
   require("configuracion.php");
   require("sessioncheck.php");
   require("utilities/bitacora.php");

   // Actualizamos el log de la sesion, como cerrada
   $query  = " UPDATE app_SysUserSessions ";
   $query .= " SET activesession = 0, fechadestroy = GETDATE() ";
   $query .= " WHERE (id_SysUser = ".$_SESSION[$appkey."id_SysUser"].") ";
   $query .= " AND   (appsession = '".$_SESSION[$appkey."appsession"]."') ";
   $query .= " AND   (phpsession = '".session_id()."') ";
   $result = mssql_query ($query);

   // Destruimos la session
   session_unset();
   session_destroy();
   $_SESSION = array();

   // Eliminamos las variables de session  
   //unset($_SESSION[$appkey."id_SysUser"]);
   //unset($_SESSION[$appkey."strPermisos"]);
   //unset($_SESSION[$appkey."id_SysUserPerfil"]);
   //unset($_SESSION[$appkey."appsession"]);
   //unset($_SESSION[$appkey."logtype"]);
   //unset($_SESSION[$appkey]);

   //Header("Location:index.php");
   echo "<meta http-equiv='REFRESH' content='0;url=index.php'>";
?>
